package com.yh.ldzl.service.impl;

import com.ruoyi.common.core.web.page.PageDomain;
import com.ruoyi.common.core.web.page.TableSupport;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.yh.ldzl.domain.QcTemplateProduct;
import com.yh.ldzl.mapper.QcTemplateProductMapper;
import com.yh.ldzl.service.QcTemplateProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QcTemplateProductServiceImpl implements QcTemplateProductService {

    @Autowired
    private QcTemplateProductMapper qcTemplateProductMapper;
    @Override
    public List<QcTemplateProduct> selectQcTemplateProductList(Long template_id) {
        return qcTemplateProductMapper.selectQcTemplateProductList(template_id);
    }

    @Override
    public boolean selectQcTemplateProductNameUnique(String item_name,Long templateId) {
        return qcTemplateProductMapper.selectQcTemplateProductNameUnique(item_name,templateId)==0;
    }

    @Override
    public boolean insertQcTemplateProduct(QcTemplateProduct qcTemplateProduct) {
        qcTemplateProduct.setCreate_by(SecurityUtils.getUsername());
        return qcTemplateProductMapper.insertQcTemplateProduct(qcTemplateProduct)>0;
    }

    @Override
    public boolean updateQcTemplateProduct(QcTemplateProduct qcTemplateProduct) {
        qcTemplateProduct.setUpdate_by(SecurityUtils.getUsername());
        return qcTemplateProductMapper.updateQcTemplateProduct(qcTemplateProduct)>0;
    }

    @Override
    public boolean deleteQcTemplateProduct(List<Long> ids) {
        return qcTemplateProductMapper.deleteQcTemplateProduct(ids)>0;
    }

    @Override
    public List<QcTemplateProduct> selectQcTemplateProductItemInformationTemplateId(QcTemplateProduct qcTemplateProduct) {
        PageDomain pageDomain = TableSupport.buildPageRequest();
        Integer pageNum = pageDomain.getPageNum();
        Integer pageSize = pageDomain.getPageSize();
        return qcTemplateProductMapper.selectQcTemplateProductItemInformationTemplateId(qcTemplateProduct);
    }

    @Override
    public QcTemplateProduct selectQcTemplateProductMaterialCode(String material_code) {
        return qcTemplateProductMapper.selectQcTemplateProductMaterialCode(material_code);
    }

    @Override
    public QcTemplateProduct selectQcTemplateProductProductCode(Long product_id) {
        return qcTemplateProductMapper.selectQcTemplateProductProductCode(product_id);
    }

    @Override
    public QcTemplateProduct selectQcTemplateProductCode(String product_code) {
        return qcTemplateProductMapper.selectQcTemplateProductCode(product_code);
    }


}
